import ValidationUtils from './ValidationUtils';
import { SimulationItemConstant as SiC } from '../constants/InputItemConstants'
import {
  SingleValidation as BiSingleValidation,
  MultipleValidationCategory as BiMultipleValidationCategory,
  MultipleValidation as BiMultipleValidation,
  MSG_REQUIRED,
  MSG_DIGIT,
  MSG_ONE_OF,
} from './BodyDataInputValidation';

/**
 * 単項目チェック定義
 */
const SingleValidation = Object.freeze(Object.assign({}, BiSingleValidation, {

  // 最高（収縮期）血圧
  [SiC.MAX_BLOOD_PRESSURE]: {
    label: SiC.MAX_BLOOD_PRESSURE.label,
    validations: [
      {
        isRequried: true,
        validate: ValidationUtils.required,
        errorMessage: (label, value) => `${label}を${MSG_REQUIRED}`,
      },
      {
        isRequried: false,
        validate: ValidationUtils.digit,
        errorMessage: (label, value) => MSG_DIGIT,
      },
      {
        isRequried: false,
        validate: (value) => ValidationUtils.maxLength(value, 3),
        errorMessage: (label, value) => MSG_ONE_OF,
      },
      {
        isRequried: false,
        validate: (value) => ValidationUtils.rangeEqual(value, 70, 210),
        errorMessage: (label, value) => `${label}は70〜210mmHgの範囲で入力してください`,
      },
    ],
  },

  // 最低（拡張期）血圧
  [SiC.MIN_BLOOD_PRESSURE]: {
    label: SiC.MIN_BLOOD_PRESSURE.label,
    validations: [
      {
        isRequried: true,
        validate: ValidationUtils.required,
        errorMessage: (label, value) => `${label}を${MSG_REQUIRED}`,
      },
      {
        isRequried: false,
        validate: ValidationUtils.digit,
        errorMessage: (label, value) => MSG_DIGIT,
      },
      {
        isRequried: false,
        validate: (value) => ValidationUtils.maxLength(value, 3),
        errorMessage: (label, value) => MSG_ONE_OF,
      },
      {
        isRequried: false,
        validate: (value) => ValidationUtils.rangeEqual(value, 30, 130),
        errorMessage: (label, value) => `${label}は30〜130mmHgの範囲で入力してください`,
      },
    ],
  },

  // HDLコレステロール
  [SiC.HDL_CHOLESTEROL]: {
    label: SiC.HDL_CHOLESTEROL.label,
    validations: [
      {
        isRequried: true,
        validate: ValidationUtils.required,
        errorMessage: (label, value) => `${label}を${MSG_REQUIRED}`,
      },
      {
        isRequried: false,
        validate: ValidationUtils.digit,
        errorMessage: (label, value) => MSG_DIGIT,
      },
      {
        isRequried: false,
        validate: (value) => ValidationUtils.maxLength(value, 3),
        errorMessage: (label, value) => MSG_ONE_OF,
      },
      {
        isRequried: false,
        validate: (value) => ValidationUtils.rangeEqual(value, 5, 170),
        errorMessage: (label, value) => `${label}は5〜170mg/dlの範囲で入力してください`,
      },
    ],
  },

  //
  // 追加分があればここに追加する
  //

}));

/**
 * 相関チェック種別
 */
let MultipleValidationCategory = Object.assign({}, BiMultipleValidationCategory, {

  //
  // 追加分があればここに追加する
  //

});

/**
 * 相関チェック定義
 */
let MultipleValidation = Object.assign({}, BiMultipleValidation, {

  //
  // 追加分があればここに追加する
  //

});

// 不要チェック定義の削除
// ・飲酒頻度、飲酒量の未入力チェック（未選択を「飲まない」として扱いたいため）
[
  BiMultipleValidationCategory.ALCOHOL_FREQUENCY,
  BiMultipleValidationCategory.ALCOHOL_AMOUNT_SAKE,
  BiMultipleValidationCategory.ALCOHOL_AMOUNT_SHOCHU,
  BiMultipleValidationCategory.ALCOHOL_AMOUNT_BEER,
  BiMultipleValidationCategory.ALCOHOL_AMOUNT_WHISKEY,
  BiMultipleValidationCategory.ALCOHOL_AMOUNT_WINE,
  BiMultipleValidationCategory.ALCOHOL_AMOUNT_ALL,
].forEach(key => {
  delete MultipleValidationCategory[key];
  delete MultipleValidation[key];
});

MultipleValidationCategory = Object.freeze(MultipleValidationCategory);
MultipleValidation = Object.freeze(MultipleValidation);

export {
  SingleValidation,
  MultipleValidationCategory,
  MultipleValidation,
}
